home *** CD-ROM | disk | FTP | other *** search
- unit MyObj;
-
- interface
-
- {$IFNDEF EXPORT}
- {$IFNDEF IMPORT}
- {$DEFINE NORMAL}
- {$ENDIF}
- {$ENDIF}
-
- type
- TMyObject = class(TObject)
- private
- FProp : integer;
- procedure SetProp(Value: integer); virtual;
- {$IFNDEF NORMAL} export; {$ENDIF}
- {$IFDEF IMPORT} abstract; {$ENDIF}
- public
- constructor Create; virtual;
- {$IFNDEF NORMAL} export; {$ENDIF}
- {$IFDEF IMPORT} abstract; {$ENDIF}
- destructor Destroy; virtual;
- {$IFNDEF NORMAL} export; {$ENDIF}
- {$IFDEF IMPORT} abstract; {$ENDIF}
- procedure Free; virtual;
- {$IFNDEF NORMAL} export; {$ENDIF}
- {$IFDEF IMPORT} abstract; {$ENDIF}
- procedure TestIt; virtual;
- {$IFNDEF NORMAL} export; {$ENDIF}
- {$IFDEF IMPORT} abstract; {$ENDIF}
- property Prop: integer read FProp write SetProp;
- end;
- TMyObjectClass = class of TMyObject;
-
- function _TMyObject: TMyObjectClass; {$IFDEF EXPORT} export; {$ENDIF}
-
- implementation
-
- uses
- WinProcs;
-
- {$IFNDEF IMPORT}
- constructor TMyObject.Create;
- begin
- inherited Create; { Call the non-virtual TObject.Create here }
- FProp := 1;
- end;
-
- destructor TMyObject.Destroy;
- begin
- inherited Destroy; { Call the virtual destructor TObject.Destroy }
- end;
-
- procedure TMyObject.Free;
- begin
- { if Self = nil, then we wouldn't be here in the first place }
- Destroy;
- end;
-
- procedure TMyObject.TestIt;
- var
- i : integer;
- begin
- for i := 1 to FProp do
- WinProcs.MessageBeep(0);
- end;
-
- procedure TMyObject.SetProp(Value: integer);
- begin
- if Value > 10 then
- FProp := 10
- else
- FProp := Value;
- end;
- {$ENDIF}
-
- function _TMyObject: TMyObjectClass; {$IFDEF IMPORT} external 'OBJDLL' index 1;
- {$ELSE}
- begin
- Result := TMyObject;
- end;
- {$ENDIF}
-
- end.
-